<template>
  <div class="map">
    <div id="container"></div>
  </div>
</template>
<script>
const BMapGL = window.BMapGL
export default {
  data() {
    return {}
  },
  mounted() {
    var map = new BMapGL.Map('container')
    // var point = new BMapGL.Point(116.404, 39.915)
    // map.centerAndZoom(point, 15)
    // 创建地址解析器实例
    var myGeo = new BMapGL.Geocoder()
    // 将地址解析结果显示在地图上，并调整地图视野
    myGeo.getPoint(
      '麓谷企业广场A2栋',
      function (point) {
        if (point) {
          map.centerAndZoom(point, 18)
          map.addOverlay(
            new BMapGL.Marker(point, { title: '麓谷企业广场A2栋' })
          )
        } else {
          alert('您选择的地址没有解析到结果！')
        }
      },
      '长沙市'
    )
  }
}
</script>
<style lang="scss" scoped>
.map,
#container {
  height: 100%;
}
</style>
